package gdr.player;
/**
 * Gestisce un insieme di statistiche
 * @author Giorgio Vitale
 *
 */
public class Statistiche {
	public static final int HP = 0;
	public static final int MP = 1;
	public static final int ATK = 2;
	public static final int DEF = 3;
	public static final int MAG = 4;
	public static final int RES = 5;
	
	public static final int STAT_NUM =6;
	
	protected int[] stats;

	public Statistiche(){
		stats = new int[STAT_NUM];
	}
	public int[] getStats() {
		return stats;
	}

	public void setStats(int[] stats) {
		this.stats = stats;
	}
	/**
	 * restituisce una particolare statistica
	 * @param stat
	 * @return
	 */
	public int getStat(int stat){
		if (stat<0 || stat>STAT_NUM) throw new IllegalArgumentException();
		return stats[stat];
	}
	/**
	 * imposta una particolare statistica
	 * @param stat
	 * @param value
	 */
	public void setStat(int stat, int value){
		if (stat<0 || stat>STAT_NUM) throw new IllegalArgumentException();
		stats[stat] = value;
	}
	/**
	 * Dato l'identificativo della statistica, ne restituisce il nome.
	 * @param stat
	 * @return
	 */
	public String getStatDescriptor(int stat){
		if (stat<0 || stat>STAT_NUM) throw new IllegalArgumentException();
		switch (stat)
		{	case HP: return "HP";
			case MP: return "MP";
			case ATK: return "ATK";
			case DEF: return "DEF";
			case MAG: return "MAG";
			case RES: return "RES";
			default: return "";
		}
	}
	
	public String toString(){
		String s = "";
		for (int i=0; i<STAT_NUM; i++)
			s+=getStatDescriptor(i)+":"+stats[i]+";";
		return "["+s.substring(0, s.length()-1)+"]";
	}
}
